<?php include("dbconfig.php"); ?>
<div class="widget w-box recents-widget">
	<h2 class="widget-title"><span><img src="images/document.jpg" width="30" height="30"> หนังสือ/เอกสาร</span2></h3>	
	
	<ul class="prl-list-line">
		<?php
			$sql = "SELECT * FROM article WHERE fix_status = 1 AND fix_article_type = 9 ORDER BY inserted_date_time DESC LIMIT 5";
			$rsd = mysql_query($sql);
			while($row = mysql_fetch_array($rsd))
			{
		?>
				<li class="clearfix">
					<article class="prl-article">
					
		<?php
				$date = new DateTime($row['inserted_date_time']);
				echo "<a href=\"single.php?id=".$row["article_id"]."\" class=\"prl-thumbnail floatleft\" target=\"_blank\">";
				if((bool)preg_match('#<img[^>]+src=[\'"]([^\'"]+)[\'"]#', html_entity_decode($row['description']), $matches))
				{
				   $imageFound = $matches[0];
				   $src = substr($imageFound, strpos($imageFound, "src"));
				}
				else
				{
				  $src = "src=\"images/default_image.png\"";
				}
				echo "<img ".$src." width=\"60\" height=\"60\" alt=\"pataniforum\"></a>";
				echo "<a class=\"recent-title\" href=\"single.php?id=".$row["article_id"]."\" title=\"\" target=\"_blank\">".iconv_substr($row["title"],0,50,'UTF-8')."</a>";
				echo "<span class=\"prl-article-meta\"><span><i class=\"fa fa-clock-o\"></i>".$date->format('d/m/Y H:i').",".iconv_substr($row["reference_st"],0,15,'UTF-8')."</span></span>";
		?>
					</article>
				</li>
		<?php
			}
			mysql_close(); 
		?>
	</ul>
	<h5><span><a href="category.php?type=9">อ่านทั้งหมด</a></span></h5>
</div>	